package py.com.alfa.escriba.gui.utils;

import org.slf4j.Logger;

@SuppressWarnings("unused")
public class LoggerUtils {
	
	private final String WHITESPACE = " ";
	private final String NEW_LINE = "\n";
	private final String TAB = "\t";
	private final String DOT = ".";
	private final String COMMA = ".";
	private final String DOLLAR = "$";
	private final String UNDERSCORE = "_";
	private final String MINUS = "-";
	private final String COLON = ":";
	private final String SEMICOLON = ";";
	private final String EQUALS = "==";
	private final String EQUAL = "=";
	private final String PIPE = "=";
	private final String BRACES = "{}";
	private final String FIFTY_EQUALS = "==================================================";
	
	private StringBuffer logBuffer;
	private Logger logger;
	
	
	public LoggerUtils(){
		setLogBuffer(new StringBuffer());
	}

	public LoggerUtils line(){
		return append(NEW_LINE);
	}
	
	public LoggerUtils tab(){
		return append(TAB);
	}
	
	public LoggerUtils whitespace(){
		return append(WHITESPACE);
	}
	
	public LoggerUtils whitespace(String arg){
		return whitespace().append(arg).whitespace();
	}
	
	public LoggerUtils braces(){
		return append(BRACES);
	}
	
	public LoggerUtils dot(){
		return append(DOT);
	}
	
	public LoggerUtils comma(){
		return append(COMMA);
	}
	
	public LoggerUtils minus(){
		return append(MINUS);
	}
	
	public LoggerUtils colon(){
		return append(COLON);
	}
	
	public LoggerUtils equal(){
		return append(EQUAL);
	}
	
	public LoggerUtils fiftyEquals(){
		return append(FIFTY_EQUALS);
	}
	
	public LoggerUtils OneHundredEquals(){
		return fiftyEquals().fiftyEquals();
	}

	public LoggerUtils append(String arg){
		if(arg != null){
			getLogBuffer().append(arg);
		}
		return this;
	}
	
	public void clear(){
		getLogBuffer().delete(0, getLogBuffer().length());
	}
	
	public LoggerUtils entry(String arg){
		line().OneHundredEquals().line().whitespace(arg).line().OneHundredEquals().line().info();
		return this;
	}
	
	public LoggerUtils entry(String arg, Object var1){
		line().OneHundredEquals().line().value(arg).line().OneHundredEquals().line().info(var1);
		return this;
	}
	
	public LoggerUtils entry(String arg, Object var1, Object var2){
		line().OneHundredEquals().line().whitespace(arg).colon().whitespace().braces().whitespace().minus().whitespace().braces().line().OneHundredEquals().line().info(var1);
		return this;
	}
	
	
	public LoggerUtils info(){
		getLogger().info(getContent());
		clear();
		return this;
	}
	
	public LoggerUtils info(String arg){
		getLogger().info(arg);
		return this;
	}
	
	public LoggerUtils info(Object arg){
		getLogger().info(getContent(), arg);
		clear();
		return this;
	}
	
	public LoggerUtils info(Object arg1, Object arg2){
		getLogger().info(getContent(), arg1, arg2);
		clear();
		return this;
	}
	
	public LoggerUtils error(String msg, Throwable t){
		getLogger().error(msg, t);
		return this;
	}
	
	public LoggerUtils value(String arg){
		whitespace(arg).colon().whitespace().braces();
		return this;
	}
	
	public String getContent(){
		return getLogBuffer().toString();
	}
	
	public Logger getLogger() {
		return logger;
	}

	public void setLogger(Logger logger) {
		this.logger = logger;
	}


	public StringBuffer getLogBuffer() {
		return logBuffer;
	}

	public void setLogBuffer(StringBuffer logBuffer) {
		this.logBuffer = logBuffer;
	}
	
	

}
